import os
file_path = "append_demo.txt"
content = "这是新追加的一行内容\n"
#自动关闭

print("真实路径：",os.path.realpath(file_path))
with open(file_path,'a',encoding='utf-8') as f:
    f.write(content)
    f.write("第二行追加内容\n")
    f.write("第三行追加内容\n")
print(f"内容已成功追加到{file_path}")